function [f , TREND_Fit] = interp_denton(DATA , FREQ , TREND_type , ta , sc , op1)

T = length(DATA);

%% Get non-nan part
idx_first = nonnan_first(DATA);
idx_last = nonnan_last(DATA);
DATA_nm = DATA(idx_first : idx_last);
T_nm = length(DATA_nm);

%% Determine trend
if TREND_type == 1
   TREND_param = polyfit((1 : T_nm)' , log(DATA_nm) , 1);
   TREND = exp((1 : FREQ * T_nm)' * TREND_param(1)/FREQ + TREND_param(2)/FREQ);
   TREND_Fit = [nan(idx_first - 1 , 1);... 
                exp((1 : T_nm)' * TREND_param(1) + TREND_param(2));...
                nan(T - idx_last , 1)];
            
elseif TREND_type == 0
   TREND = ones(FREQ * T_nm , 1);
   TREND_Fit = [nan(idx_first - 1 , 1);...
                ones(T_nm , 1);...
                nan(T - idx_last , 1)];
end

%% Interpolate
DATA_denton_nm = denton(DATA_nm , TREND , ta , sc , FREQ , op1);

%% Fill in NaNs
f = [nan((idx_first - 1) * FREQ , 1);...
     DATA_denton_nm.y/FREQ;...
     nan((T - idx_last) * FREQ , 1)];

end